package com.lagou.rocketmq.dao;

import com.lagou.rocketmq.model.GoodsQuantity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
 * @ClassName GoodsQuantityDao
 * @Description TODO
 * @Author xsq
 * @Date 2020/11/25 15:46
 **/
@Repository
public interface GoodsQuantityDao extends JpaRepository<GoodsQuantity, Long> {


    @Modifying
    @Query(value = "update goods_quantity set quantity = quantity - 1 where quantity>=0", nativeQuery = true)
    void updateQuantity();

    @Modifying
    @Query(value = "update goods_quantity set quantity = quantity + 1", nativeQuery = true)
    void addQuantity();
}
